
package com.css.fxfzaqbz.modules.supergraph.repository.impl;

import com.css.fxfzaqbz.constants.YNEnum;
import com.css.fxfzaqbz.modules.data.entity.Site;
import com.css.fxfzaqbz.modules.maps.entity.ProfessionMap;
import com.css.fxfzaqbz.modules.supergraph.repository.SupergraphRepository;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;


/**
 * @author y1fan
 * @create 2023-02-07 19:48
 */

@Repository
public class SupergraphRepositoryImpl implements SupergraphRepository {


    @Resource
    JdbcTemplate jdbcTemplate;

    @Override
    public List<ProfessionMap> getSupergraph() {
        String sql="select * from sys_profession_map where  del_flag ='"+ YNEnum.N +"'";
        try {
            return  jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(ProfessionMap.class));
        } catch (DataAccessException e) {
           return null;
        }
    }

    @Override
    public Site getSiteByName(String zdmb) {
        String sql="select * from sys_site where  del_flag ='"+ YNEnum.N +"' and ss_jzwmc='"+zdmb+"' limit 1";
        try {
            return jdbcTemplate.queryForObject(sql,new BeanPropertyRowMapper<>(Site.class));
        } catch (DataAccessException e) {
            return null;
        }
    }
}

